package com.health.exhandler;

import com.health.domain.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author ghy
 * @version 1.0
 * @since 2025-06-20 20:58
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    /**
     * 处理项目中所有的异常
     * @param exception 抛出的异常
     * @return
     */
    @ExceptionHandler(Exception.class)
    public Result<String> handleException(Exception exception){
        log.error("异常处理器handleException：{}", exception.getMessage());
        return Result.error(exception.getMessage());
    }

}
